package com.example.comitclx1.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Slf4j
@Component
//@Aspect  //aop类
public class TimeAspect {
    @Around("execution(* com.example.comitclx1.service.*.*(..))")//切入点表达式
    public Object recordTime(ProceedingJoinPoint joinPoint) throws Throwable {
        //开始时间
        long begin = System.currentTimeMillis();
        //调用原始方法
        Object proceed = joinPoint.proceed();
        //结束时间
        long end = System.currentTimeMillis();
        log.info(joinPoint.getSignature()+"运行{}ms",end-begin);
        return proceed;
    }
}
